import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘远望
 * Date: 2025-04-16
 * Time: 20:24
 */
public class Test {
    public static void main(String[] args) {
        BinaryTree binaryTree = new BinaryTree();
        BinaryTree.TreeNode root = binaryTree.creakTree();

        //前序遍历
        System.out.println("前序遍历");
        binaryTree.preOrder(root);
        System.out.println();

        List<Character> list = binaryTree.preOrder2(root);
        for(char x : list){
            System.out.print(x + " ");
        }
        System.out.println();

        List<Character> list2 = binaryTree.preOrder3(root);
        for (char x : list2){
            System.out.print(x + " ");
        }
        System.out.println();

        binaryTree.preOrder4(root);
        System.out.println();

        //中序遍历
        System.out.println("中序遍历");
        binaryTree.inOrder(root);
        System.out.println();

        binaryTree.inOrder2(root);
        System.out.println();

        //后序遍历
        System.out.println("后序遍历");
        binaryTree.postOrder(root);
        System.out.println();

        binaryTree.postOrder2(root);
        System.out.println();

        //层序遍历
        System.out.println("层序遍历");
        binaryTree.levelOrder(root);
        System.out.println();

        //层序遍历2
        System.out.println("层序遍历2");
        List<List<Character>> ret3 = binaryTree.levelOrder2(root);
        for(List<Character> x: ret3){
            for(Character Y : x){
                System.out.print(Y + " ");
            }
        }
        System.out.println();

        //节点的个数
        System.out.println("节点的个数");
        binaryTree.size(root);
        System.out.println(BinaryTree.nodeSize);
        System.out.println(binaryTree.size2(root));

        //叶子的数量
        System.out.println("叶子的数量");
        binaryTree.leafSize(root);
        System.out.println(BinaryTree.leafSize);
        System.out.println(binaryTree.leafSize2(root));

        //获得第k层节点的个数
        System.out.println("第k层节点的个数");
        int size3 = binaryTree.getLevelNode(root,3);
        System.out.println(size3);

        //获得树的高度
        System.out.println("获得树的高度");
        int size4 = binaryTree.getHight(root);
        System.out.println(size4);

        //在二叉树中查找val值
        System.out.println("在二叉树中查找val值");
        BinaryTree.TreeNode ret = binaryTree.getVal(root,'E');
        System.out.println(ret);

        //反转二叉树
        System.out.println("反转二叉树");
        BinaryTree.TreeNode ret2 = binaryTree.inverTree(root);
        //调用前序遍历
        binaryTree.preOrder(ret2);
        System.out.println();


    }
}
